import Vue from 'vue'
import Router from 'vue-router'
import Login from '@/views/login'
import Main from '@/views/main'

import UserAdd from '@/views/user/add'
import UserList from '@/views/user/list'
import ProdAdd from '@/views/product/add'
import ProdList from '@/views/product/list'
import NotFound from '@/views/404'

Vue.use(Router)

export default new Router({
  mode: 'history',  /*路径不带 # 符号*/
  routes:[
    {
      path:'/',
      redirect:"/login", //访问当前路径"/"会重定向到/login
    },
    /*path是自定义的*/
    {
      name:'login',
      path:'/login',
      component:Login
    },
    {
      name:'main',
      path:'/main',
      component:Main,
      children:[
        /* :id类似占位符,用来传递参数*/
        {name:'UserAdd',path:'/user/add/:id',component:UserAdd},
        {name:'UserList',path:'/user/list/:id',component:UserList,props:true}
      ]
    },
    {
      path:'/home',
      redirect:'/main'
    },
    {
      path:'*', /*上面的所有路径不匹配,就匹配*的路径*/
      component:NotFound
    }
  ]

})
